package com.oj.common.security.config;

import com.oj.common.security.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description
 * @Author bin
 * @Date 2025/4/16
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    // 注入拦截器
    //注入的组件为空可能是因为手动new了实例 导致无法正常加载
    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/**/login")
                .excludePathPatterns("/**/redirect")
                .excludePathPatterns("/**/sendCode")
//                .excludePathPatterns("/**/semiLogin/**")
        ;
    }
}
